﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<form id="form1">
    <div style="padding-top: 20px; margin-right: 30px;">
        <table class="form">
            <tr>
                <td class="formTitle">
                    <span class="required">*</span>收费大类：
                </td>
                <td class="formValue formDdlSelectorTd">
                    <select class="form-control required" id="dlCode" name="dlCode">
                        <option value="">==请选择==</option>
                    </select>
                </td>
                <td class="formTitle" style="width:120px;">治疗师：</td>
                <td class="formValue">
                    <input id="gh" name="gh" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <td class="formTitle">比例：</td>
                <td class="formValue">
                    <input id="bl" name="bl" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">月超额：</th>
                <td class="formValue">
                    <input id="yce" name="yce" type="text" class="form-control" placeholder="" />
                </td>
                <th class="formTitle">月超额比例：</th>
                <td class="formValue">
                    <input id="ycebl" name="ycebl" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">第二月超额：</th>
                <td class="formValue">
                    <input id="deyce" name="deyce" type="text" class="form-control" placeholder="" />
                </td>
                <th class="formTitle">第二月超额比例：</th>
                <td class="formValue">
                    <input id="deycebl" name="deycebl" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">第三月超额：</th>
                <td class="formValue">
                    <input id="dsyce" name="dsyce" type="text" class="form-control" placeholder="" />
                </td>
                <th class="formTitle">第三月超额比例：</th>
                <td class="formValue">
                    <input id="dsycebl" name="dsycebl" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">年超额：</th>
                <td class="formValue">
                    <input id="nce" name="nce" type="text" class="form-control" placeholder="" />
                </td>
                <th class="formTitle">年超额比例：</th>
                <td class="formValue">
                    <input id="ncebl" name="ncebl" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">固定金额：</th>
                <td class="formValue">
                    <input id="blhgdje" name="blhgdje" type="text" class="form-control" placeholder="" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">备注：</th>
                <td class="formValue" colspan="3">
                    <textarea id="bz" name="bz" class="form-control" style="height: 60px;"></textarea>
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">状态：</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="zt" name="zt" type="checkbox" checked="checked">
                        <label for="zt">有效</label>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.najax({
                url: "/KPI/Therapeutist/GetConfigFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                success: function (data) {
                    $("#form1").formSerialize(data);

                    if (data.gh && data.zlsxm && data.zlsId) {
                        $('#gh').val(data.zlsxm);
                        selectedRehabDoctorStaffId = data.zlsId;
                        selectedRehabDoctorStaffGh = data.gh;
                    }
                    else {
                        $('#gh').val('');
                    }
                }
            });
        }
        else {
            $('#zt').click(function () {
                return false;
            });
        }
    });

    var selectedRehabDoctorStaffId;
    var selectedRehabDoctorStaffGh;

    function initControl() {
        $("#dlCode").bindSelect({
            url: "/SystemManage/SysChargeCategory/GetListJson?dllbs=2",
        });

        //绑定 治疗师选择 树
        $('#gh').focus(function () {
            var initIdSelected = selectedRehabDoctorStaffId;
            $.modalOpen({
                id: "StaffCorrelation",
                title: "选择治疗师",
                url: "/SystemManage/SysStaff/Selector?single=true&isContansChildOrg=false&callbackType=json&dutyCode=RehabDoctor&initIdSelected=" + initIdSelected,
                showleftlalbel: false,
                width: "650px",
                height: "570px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick(function (data) {
                        staffTreeCallback(data);
                    });
                }
            });
        });

    }

    //治疗师树 选择 回调
    function staffTreeCallback(treeSeleData) {
        if (treeSeleData.length == 1) {
            $('#gh').val(treeSeleData[0].text);
            selectedRehabDoctorStaffId = treeSeleData[0].id;
            selectedRehabDoctorStaffGh = treeSeleData[0].value;
        }
        else {
            $('#gh').val('');
            selectedRehabDoctorStaffId = '';
            selectedRehabDoctorStaffGh = '';
        }
    }

    function AcceptClick(callBack) {
        if (!$('#form1').formValid()) {
            return false;
        }
        var postData = $("#form1").formSerialize();
        postData['gh'] = selectedRehabDoctorStaffGh;
        $.submitForm({
            url: "/KPI/Therapeutist/SubmitTherapeutistPSConfig?keyValue=" + keyValue,
            param: postData,
            success: function () {
                callBack();
                $.modalClose();
            }
        })
    }
</script>